<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1,user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <title>{$title}</title>
    <css href="__PUBLIC__/css/reset.css"/>
    <css href="__PUBLIC__/css/style.css"/>
    <css href="__PUBLIC__/css/bootstrap.min.css"/>
    <css href="__PUBLIC__/css/login.css"/>
    <js href="__PUBLIC__/js/Jquery/jquery-1.7.1.js"/>
    <script language="JavaScript">
        /**
         * 登录验证
         */
        function check_login(){
            var reg_p=/^(13[0-9]|15[0|1|2|3|6|7|8|9]|18[0|2|3|5|6|7|8|9]|17[0])\d{8}$/;
            var reg_e=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
            var username=document.getElementById('username').value;
            var password=document.getElementById('password').value;
            var verify=document.getElementById('verify').value;
            var result=document.getElementById("result");
            var messages=document.getElementById("messages");
            var res_p=username.match(reg_p);
            var res_e=username.match(reg_e);
            var next;
            //判断复选框是否被选中
            if ($("#next").is(":checked")) {
                next = 'week';
            }
            if(res_p || res_e){
                $.post("<?php echo U('/loginCheck');?>",{username:username,password:password,week:next,verify:verify},function(msg){
                    if(msg=="1"){
                        messages.innerHTML="请填写正确的手机或邮箱格式。";
                        result.style.display="block";
                    }else if(msg=="2"){
                        messages.innerHTML="您输入的密码和账号不匹配，请重新输入。";
                        result.style.display="block";
                    }else if(msg=="3"){
                        messages.innerHTML="该手机号未注册。";
                        result.style.display="block";
                    }else if(msg=="4"){
                        messages.innerHTML="该邮箱未注册。";
                        result.style.display="block";
                    }else if(msg=="5"){
                        messages.innerHTML="验证码错误。";
                        result.style.display="block";
                    }else if(msg=="0"){
                        result.style.display="none";
                        if(result.style.display=="none"){
                            window.location.href="<?php echo U('/index');?>";
                        }else{
                            messages.innerHTML="错误信息未处理完成。";
                            result.style.display="block";
                        }
                    }else{
                        alert(msg);
                    }
                });
            }else{
                messages.innerHTML="请填写正确的账号格式。";
                result.style.display="block";
            }

        }
    </script>
</head>
<body>
<include file="./Application/Home/View/nav.html"/>
<div class="container">
    <div class="row" style="margin-top:20px;">
        <div class="col-lg-6">
            <img src="__PUBLIC__/images/LOGO.png" class="img-responsive"/>
        </div>
    </div>

    <div class="row" style="margin-top:20px;">
        <div class="col-lg-6">
            <img src="__PUBLIC__/images/people.png" class="img-responsive"/>
        </div>
        <div class="col-lg-6">
            <form role="form" id="login-form" method="post">

                <div id="login-title">
                        <span>
                            <div style="float: left;">///////////////////</div>
                            <label>登录</label>
                            <div style="float: right;">///////////////////</div>
                        </span>
                </div>
                <!--error tips-->
                <include file="./Application/Home/View/error_tips.html"/>
                    <div id="login-content">
                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label">手机/邮箱</label>
                            <input type="text" name="username" id="username" class="form-control col-sm-10" required="required" placeholder="请输入您的手机或邮箱"/>
                        </div>
                        <div class="form-group">
                            <label for="password" class="col-sm-2 control-label">密&nbsp;&nbsp;&nbsp;码</label>
                            <input type="password" name="password" id="password" class="form-control col-sm-10"  required="required" placeholder="请输入您的密码" maxlength="20"/>
                        </div>
                        <div class="form-group">
                            <label for="verify" class="col-sm-2 control-label">验&nbsp;证&nbsp;码</label>
                            <input type="text" name="verify" id="verify" class="form-control col-sm-10" required="required" placeholder="输入验证码" maxlength="4"/>
                            <img src="{:U('/verify')}" alt="验证码" title="单击变换验证码" onclick="change(this)" style="cursor: pointer; width: 34%;height: 40px;float: left; border-radius: 6px;"/>
                        </div>
                        <div class="form-group">
                            <p style="padding-left: 20px; float: left;">
                                <input name="next" id="next" style="width: 17px;height: 17px;" type="checkbox"/>
                                <label for="next" style="color: #ff6666; font-size: 18px;font-family: '微软雅黑,宋体'; line-height: 50px; cursor: pointer;">一周内自动登录</label>
                            </p>

                            <p style="padding-right: 20px; float: right;">
                                <a style="color: #afafaf; font-size: 18px;font-family: '微软雅黑,宋体'; line-height: 60px; "
                                   href="javascript:void (0)">忘记密码？</a>
                            </p>
                        </div>
                    </div>

                <div id="login-bottom">
                    <div class="form-group">
                        <div class="col-sm-offset-3 col-sm-10">
                            <input type="button" onclick="check_login()" class="btn btn-default btn-lg active" value="登录"/>
                        </div>
                    </div>
                    <div style="float: right; margin-right: 20px; padding-bottom: 20px;color: #afafaf; font-size: 20px;font-family: '微软雅黑,宋体';">
                        <a class="help-block" href="{:U('/mstreg')}">快速注册&gt;&gt;</a>
                    </div>
                </div>
            </form>
        </div>
            <script type="text/javascript">
                function change(obj) {
                    obj.src = "{:U('/verify')}?_=" + Math.random();
                }
            </script>
    </div>
</div>
<!--	引入底部	-->
<include file="./Application/Home/View/footer.html"/>
</body>
</html>